<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CSS样式更新与AJAX</title>
</head>
<body>
    <div id="nav"></div>
    <script>
        var xhr = new XMLHttpRequest();
        xhr.open('GET', 'loginStatus.json', true);
        xhr.onreadystatechange = function() {
            if (xhr.readyState == 4 && xhr.status == 200) {
                var data = JSON.parse(xhr.responseText);
                if (data.isLogin) {
                    document.getElementById('nav').innerHTML = '<a href="logout.php">Logout</a>';
                } else {
                    document.getElementById('nav').innerHTML = '<a href="login.php">Login</a>';
                }
            }
        }
        xhr.send();
    </script>
</body>
</html>